import "./index.less"

import { message } from "antd"

message.config({
	maxCount: 1,
	duration: 2
})

export type TOAST_METHOD = "error" | "info" | "success" | "warning" | "destroy"

export class Toast {
	static error(content: string, duration?: number) {
		// this.destroy();
		message.error({
			content,
			icon: " ",
			className: "message-class",
			duration
		})
	}
	static info(content: string, duration?: number) {
		// this.destroy();
		message.error({
			content,
			icon: " ",
			className: "message-class",
			duration
		})
	}
	static success(content: string, duration?: number) {
		message.open({
			type: "success",
			content: content,
			duration
		})
	}
	static warning(content: string, duration?: number) {
		message.open({
			type: "warning",
			content: content,
			duration
		})
	}
	static destroy() {
		try {
			message.destroy()
		} catch (error) {
			console.log(error)
		}
	}
}
